package cn.getech.data.development.mapper;

import cn.getech.data.development.dto.JobHistoryDto;
import cn.getech.data.development.entity.JobDepHistory;
import cn.getech.data.development.entity.JobRunHistory;
import cn.getech.data.development.entity.JobStaticDay;
import cn.getech.data.development.entity.ProcInfo;
import cn.getech.data.development.model.dto.JobRunTOPDto;
import cn.getech.data.development.model.qo.CMClusterSearchTimeQO;
import cn.getech.data.development.model.vo.WorkJobAndDepVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;


/**
 * <p>
 * 任务执行历史表 Mapper 接口
 * </p>
 *
 * @author zenith
 * @since 2018-08-27
 */
@Mapper
public interface JobRunHistoryMapper extends BaseMapper<JobRunHistory> {
    List<Integer> selectIdList(Map<String,Object> map);

    /**
    * @Description 查询队列名称列表
    * @Author  chengweiping
    * @Date   2021/1/28 14:44
    */
    List<String> selectQueueNameList();

    /**
    * @Description 根据jobid查询job的运行日志记录数据
    * @Author  hujz
    * @Date   2019/8/19 11:41
    * @Param
    * @Return
    * @Exception
    *
    */
    List<JobRunHistory> selctListByIdLimit(@Param("limitSize") Integer limitSize, @Param("jobId") Integer jobId);

    JobRunHistory selctListByIdOne(@Param("jobId") Integer jobId);

    JobRunHistory selctListByJobIdOne(@Param("jobId") Integer jobId);

    List<JobRunHistory> getInfoByJobId(@Param("jobIds") List jobIds);

    void batchUpdateStatus(@Param("jobRunHistoryList") List<JobRunHistory> jobRunHistoryList);

    void batchUpdateKillStatus(@Param("jobRunHistoryList") List<JobRunHistory> jobRunHistoryList);

    List<String> getOozieIdByDepOozieId(@Param("depOozieIds") List depOozieIds);


    IPage<JobRunHistory> queryPage(Page<JobRunHistory> page, @Param("params") Map<String, Object> params);



    List<JobRunHistory> selectAllRunningList();


    void removeLogic(JobDepHistory jobDepHistory);

    List<JobRunTOPDto> runTimeTop(@Param("cmClusterSearchTimeQO") CMClusterSearchTimeQO cmClusterSearchTimeQO);

    List<JobStaticDay> selectCountFailNum(@Param("searchTime")String searchTime);

    /**
     *  查询所有作业流与作业流依赖
     */
    IPage<WorkJobAndDepVO> queryAllJobAndDepHistoryPage(Page<WorkJobAndDepVO> page, @Param("params") Map<String, Object> params);

    /**
    * @Description 查询所有作业流与作业流依赖包含的项目ID列表
    * @Author  chengweiping
    * @Date   2021/3/25 13:52
    */
    List<Long> queryAllJobAndDepProcId(@Param("params") Map<String, Object> params);

    List<ProcInfo> listJobs(@Param("jobInfoIds")List<Integer> jobInfoIds, @Param("type")Integer type);

    List<Long> logUsers(@Param("jobInfoIds")List<Integer> jobInfoIds, @Param("type")Integer type);

    List<JobRunHistory> selectRunningListLimit3(@Param("jobId") Integer jobId);

    IPage<JobHistoryDto> queryAllJobsHistoryPage(Page<JobHistoryDto> page,@Param("params")  Map<String, Object> params);

    List<JobRunHistory> selectListRunAndStop(@Param("oozieIds") List<String> oozieIds);
}
